/**
 * Copyright (C), 2018-2018, https://blog.fundodoo.com
 * Author:   醉探索戈壁
 * Date:     2018/7/15 上午10:52
 * Description: StaticDataController
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.fundodoo.blog.aggrid.controller;

import com.fundodoo.blog.aggrid.model.Country;
import com.fundodoo.blog.aggrid.model.Sport;
import com.fundodoo.blog.aggrid.repositories.CountryRepository;
import com.fundodoo.blog.aggrid.repositories.SportRepository;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author 醉探索戈壁
 * @create 2018/7/15 上午10:52
 * @since 1.0.0
 */
@CrossOrigin(origins = "http://localhost:4200")
@RestController
public class StaticDataController {

    private final CountryRepository countryRepository;
    private final SportRepository sportRepository;
    public StaticDataController(CountryRepository countryRepository,
                                SportRepository sportRepository) {
        this.countryRepository = countryRepository;
        this.sportRepository = sportRepository;
    }
    @GetMapping("/countries")
    public Iterable<Country> getCountries() {
        return countryRepository.findAll();
    }
    @GetMapping("/sports")
    public Iterable<Sport> getSports() {
        return sportRepository.findAll();
    }

}
